

package org.jetnuke.modules.blog;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.velocity.VelocityContext;
import org.jetnuke.common.ActionForward;
import org.jetnuke.common.IAction;
import org.jetnuke.common.IAdminInfo;
import org.jetnuke.common.IModuleInfo;
import org.jetnuke.common.IUserInfo;
import org.jetnuke.dao.BlogUserSettingsDAO;
import org.jetnuke.dao.DataAccessDriver;
import org.jetnuke.entities.BlogUserSettings;
import org.jetnuke.servlets.utilities.StringUtils;
import org.jetnuke.util.JetUtil;


public class UpdateUserSettings implements IAction {
	int max_number_posts;
	String title, description;
	String title1,title2,title3,title4,title5;
	String content1,content2,content3,content4,content5;
	public void setTitle1(String title1) {
		this.title1 = StringUtils.filterText(title1,true);
	}

	public void setTitle2(String title2) {
		this.title2 = StringUtils.filterText(title2,true);
	}

	public void setTitle3(String title3) {
		this.title3 = StringUtils.filterText(title3,true);
	}

	public void setTitle4(String title4) {
		this.title4 = StringUtils.filterText(title4,true);
	}

	public void setTitle5(String title5) {
		this.title5 = StringUtils.filterText(title5,true);
	}

	public ActionForward exec(HttpServletRequest request,
			HttpServletResponse response, VelocityContext vc, IModuleInfo info,
			String op, IUserInfo ui, IAdminInfo ai) throws Exception {
		if(ui==null || ui.getID()<2)
			return null;
		BlogUserSettingsDAO busm=DataAccessDriver.getInst().newBlogUserSettingsDAO();
		BlogUserSettings bus=busm.retrieveByPk(ui.getID());
		bus.setDESCRIPTION(description);
		bus.setMAXNUMBERPOST(max_number_posts);
		
		bus.setTITLE(title);
		bus.setBLOCKTITLE1(title1);
		bus.setBLOCKTITLE2(title2);
		bus.setBLOCKTITLE3(title3);
		bus.setBLOCKTITLE4(title4);
		bus.setBLOCKTITLE5(title5);
		bus.setBLOCKCONTENT1(content1);
		bus.setBLOCKCONTENT2(content2);
		bus.setBLOCKCONTENT3(content3);
		bus.setBLOCKCONTENT4(content4);
		bus.setBLOCKCONTENT5(content5);
		busm.update(bus);
		JetUtil.redirect(vc,response,request.getContextPath()+"/do/blog/your_blog");
		return null;
	}

	public void setDescription(String description) {
		this.description = StringUtils.filterText(description,false);
	}

	public void setMax_number_posts(int max_number_posts) {
		this.max_number_posts = max_number_posts;
	}

	public void setTitle(String title) {
		this.title = StringUtils.filterText(title,true);
	}

	public void setContent1(String content1) {
		this.content1 = StringUtils.filterText(content1,false);
	}

	public void setContent2(String content2) {
		this.content2 = StringUtils.filterText(content2,false);
	}

	public void setContent3(String content3) {
		this.content3 = StringUtils.filterText(content3,false);
	}

	public void setContent4(String content4) {
		this.content4 = StringUtils.filterText(content4,false);
	}

	public void setContent5(String content5) {
		this.content5 =StringUtils.filterText(content5,false);
	}

}
